package com.esdemo.service.impl;

import com.esdemo.dao.ShoppingUserMapper;
import com.esdemo.entity.ShoppingUser;
import com.esdemo.service.ShoppingUserService;
import com.esdemo.utils.JwtTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ShoppingUserServiceImpl implements ShoppingUserService {

    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    @Autowired
    private ShoppingUserMapper shoppingUserMapper;

    @Override
    public String login(String username, String password) {
        ShoppingUser shoppingUser=shoppingUserMapper.login(username,password);
        if (null!=shoppingUser){
            return jwtTokenUtil.generateToken(shoppingUser);
        }
        return null;
    }
}
